package com.wangbo.concurrentLinkedQueue;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.concurrent.ConcurrentLinkedQueue;

@Slf4j
@Component
public class CLQScheduleTask {
    public final ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<>();

    {
        for (int i = 0; i < 100; i++) {
            queue.add(i);
        }
    }

    /**
     *
     */
    @Scheduled(initialDelay = 2000L, fixedDelay = 1000L)
    public void test01() {
        log.info("队列大小：{}", queue.size());
        Integer item = queue.poll();
        log.info("弹出项：{}", item);
        int a = 1 / 0;
    }
}
